<?php

namespace App\Http\Controllers;

use App\Traits\Admin\DashboardViewShareDataTrait;
use Illuminate\Http\Request;
use Spatie\Permission\Models\Permission;

class PermissionController extends Controller
{
    use DashboardViewShareDataTrait;
    public function index(?string $module = null)
    {
        $this->shareData();
        return view('admin.permission.index', [
            'title' => '权限管理',
            'activeModule' => 'core',
            'activeMenu' => 'core.permissions',
            'permissions' => Permission::orderBy('id', 'desc')->paginate(2)->withQueryString(),
        ])->fragmentIf(request()->hasHeader('HX-Request'), 'content');
    }

    public function delete(\Spatie\Permission\Models\Permission $permission)
    {
        $permission->delete();
    }
}
